var result='';
$(function () {
	var arr={
		hf_s_id:"WD11",
		hf_srv_id:"Av_jcheckout",
		hs_action_id:"display",
		hs_scn_id:''
	};
	getAjaxRequest(arr,function(result) {
		if (result.bs_result==BS_RESULT.OK){
			//基本信息
			$('.DrinksBeverages .info p').eq(0).find('span').html(result.bs_first_name+" "+result.bs_family_name);
			$('.DrinksBeverages .info p').eq(1).find('span').html(result.bs_address);
			$('.DrinksBeverages .info p').eq(2).find('span').html(result.bs_cont_bef_del_phone);
			$('.DrinksBeverages .info p').eq(3).find('span').html(result.bs_cont_bef_del);
			$('.DrinksBeverages .info p').eq(4).find('span').html(result.bs_cus_dft_cmt);
			$('.DrinksBeverages .info p').eq(5).find('span').html(result.bs_delivery_time);
			$('.DrinksBeverages .info p').eq(6).find('span').html(result.bs_pay_mtd);
			$('.DrinksBeverages .info p').eq(7).find('span').html(result.bs_rec_e_inv_ind);
			$('.DrinksBeverages .info p').eq(8).find('span').html(result.bs_octopus_no);

			//订单详情
			var bc_jcart=result.bc_jcart;
			var bvc_cart_item=bc_jcart.bvc_cart_item;
			var order_str='';
			for (var i=0;i<bvc_cart_item.length;i++){
				order_str+='<div class="item">'+
					'<p>'+bvc_cart_item[i].bs_brand+" "+bvc_cart_item[i].bs_volume+'<span class="mui-pull-right">$'+bvc_cart_item[i].bj_item_tot+' </span></p>'+
					'<p>Qty  '+bvc_cart_item[i].bj_qty+'</p>'+
					'</div>';
			}

			$('.detailinfo').html(order_str);
			$('.totalPrice em').html(bc_jcart.bj_total_item_count);
			$('.totalPrice span').html('$'+bc_jcart.bj_total_item_amount);

			$('.Offers .content').html('');

			$('.check p').eq(0).find('span').html('$'+bc_jcart.bj_wd2_saving);
			$('.check p').eq(1).find('span').html('$'+bc_jcart.bj_total_del_chg_amount);
			$('.check p').eq(2).find('span').html('$'+bc_jcart.bj_wd2_discount_no_cc_no_coupon);
			$('.check p').eq(3).find('span').html('$'+bc_jcart.bj_total_item_amount);
		}
	})

})

$('.confirmBtn a').on('tap',function(){
	var arr={
		hf_s_id:"WD11",
		hf_srv_id:"Av_jcheckout",
		hs_action_id:"next",
		hs_scn_id:'pay_mtd'
	};
	getAjaxRequest(arr,function(result) {
		if (result.bs_result==BS_RESULT.OK){
			sessionStorage.setItem("bc_jorder",JSON.stringify(result.bc_jorder));
			location.href=MPJ.base+"/pages/order/confirm-complete.jsp";
		}else{
			dialog('Message', result.bs_message, 1);
			var $dialog = $('#dialog');
			$dialog.show();
			$dialog.find('.comfirmBtn').one('click', function() {
				$dialog.hide();
				$dialog.remove();
			});

		}
	})
})
